#include <stdio.h>
#include "money.h"

int main()
{

	float goods_price = 3.2;
	int getmoney_count = 0;
	int ret;
	char flo[20] = {0};
	char *getmoneystr = "money:";
	char wrfiBuf[254] = {0};
	int recveMoney = 0;
	float needOutMoney;
	float noOutMoney;
	int outB10;
	//1,打开现金设备
	openMoneyDevice();
	//2,打开收银机
	openGetMoney();
	//3.开始收钱
				
	while(1)
	{
		memset(wrfiBuf,0,sizeof(wrfiBuf));
		recveMoney = getMoney();//获取金额
		getmoney_count += recveMoney;

		//得到的金额总数大于购买的金额
		if(getmoney_count >=goods_price)
		{
			//关闭收银机
			closeGetMoney();
			printf("已放入 = %d\n",getmoney_count );

			needOutMoney = getmoney_count - goods_price;				
			break;	
		}
	}
	//4.结算
	alac( needOutMoney,&noOutMoney,&outB10); // 进入找零
	//5.关闭现金设备
	closeMoneyDevice();

	return;

}
